import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;

import javax.imageio.ImageIO;


public class SetSubImages {


	public SetSubImages() throws IOException{
		
		
		
		URL url = this.getClass().getResource("Files/SpriteSheet.png");
		BufferedImage SubImage = ImageIO.read(url);
		int x = 0;
		int y = 0;
		
		for(int i = 0; i < VarHolder.ArrayMax; i++){
			if(y > 600){
				x = 0;
				y = 0;
			}
			if(x > 460){
				x = 0;
				y += VarHolder.TileHeight+1;
			}
			VarHolder.Blocks[i] = SubImage.getSubimage(x,y,(int)(VarHolder.TileHeight+1),(int)(VarHolder.TileWidth+1));	
			if(i > 0 && i <= 200){
				VarHolder.TileType[i] = 1; 
				VarHolder.Tile[i] = VarHolder.Blocks[1];
			}
			if(i > 200 && i <= VarHolder.ArrayMax){
				VarHolder.TileType[i] = 5; 
				VarHolder.Tile[i] = VarHolder.Blocks[5];
			}
			
			if(i >= VarHolder.ArrayMax-1){
				//LoadLevel.Load();
			}
			
			x += VarHolder.TileWidth+1;
		}
		
		VarHolder.PreviewBlock = SubImage.getSubimage(0,0,(int)(VarHolder.TileHeight+1),(int)(VarHolder.TileWidth+1));
	}

}
